<html lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>remote &lt;video&gt; with local src</title>

        <script>

            var video = null;
            var console = null;
            var testEnded = false;

            function endTest()
            {
                consoleWrite("<br>END OF TEST");
                testEnded = true;
                if (window.testRunner)
                    testRunner.notifyDone();     
            }
            function hanged()
            {
                consoleWrite("FAIL: timed out");
                if (window.testRunner)
                    testRunner.notifyDone();  
            }

            function logConsole()
            {
                if (!console && document.body) {
                    console = document.createElement('div');
                    document.body.appendChild(console);
                }
                return console;
            }
            
            function consoleWrite(text)
            {
                if (testEnded)
                    return;
                logConsole().innerHTML += text + "<br>";
            }

            function logEvent(evt)
            {
                consoleWrite("EVENT(" + evt.type + ")");
            }

            function error(evt)
            {
                logEvent(evt)
                consoleWrite("");
                consoleWrite("<span style='color:green'>SUCCESS: local movie failed to load</span>");
                endTest();
            }

            function loadedmetadata(evt) 
            { 
                logEvent(evt);
                consoleWrite("");
                consoleWrite("<span style='color:red'>FAIL: local movie loaded successfully</span>");
                endTest();
            }

            var localMovie = "file:///tmp/web_tests/media/content/test.mp4";
            if (window.testRunner) {
                localMovie = testRunner.pathToLocalResource(localMovie);
                testRunner.dumpAsText();
                testRunner.waitUntilDone();
            }
            setTimeout(hanged, 10000);

            function test() {

                video = document.getElementById("vid");

                video.addEventListener("error", error);

                video.addEventListener('loadedmetadata', loadedmetadata);

                video.src=localMovie;
            }
        </script>
    
    </head>

    <body onLoad="test()">

        <video id='vid' controls></video>

        <p>Test that a remote video element can not use a local 'src'</p>
        <p>This test only works in DRT</p>

    </body>
</html>
